#include <iostream>
#include <QCoreApplication>
#include <FlatpakInfo.h>

#define out qDebug()

using namespace Flatpak;

QString makespace(int count, QString prefix) {
    QString result = "";
    int remain = count - prefix.length();
    for (int i = 0; i < remain; i++)
    {
        result.append(" ");
    }
    return result;
}

int main(int argc, char** argv) {

    QCoreApplication app(argc, argv);

    // org.gnome.Sdk
    QString package = "org.gnome.Sdk";
    auto location = Info().show_location().setPackage(package).run();
    auto origin = Info().show_origin().setPackage(package).run();
    auto commit = Info().show_commit().setPackage(package).run();
    auto ref = Info().show_ref().setPackage(package).run();
    auto metadata = Info().show_metadata().setPackage(package).run();
    auto extensions = Info().show_extensions().setPackage(package).run();
    

    // out << "location:   " << location;
    // out << "origin:     " << origin;
    // out << "commit:     " << commit;
    // out << "ref:        " << ref;
    
    // std::cout << "metadata:   " << metadata.toStdString();
    std::cout << "extensions: \n" << extensions.toStdString();

    // QStringList lines = Info().show_location().setPackage("org.gnome.Sdk").run().split("\n");
    // for (auto s : lines)
    // {
    //     QStringList ss = s.split("\t");
    //     auto prefix = QString("%1(%2)").arg(ss[0]).arg(ss[1]);
    //     out << prefix + makespace(20, prefix) + "  --  " + ss[2];
    // }

    return 0;
}